﻿@using System.Globalization
@using Moonglade.Core
@using Moonglade.DateTimeOps
@model Moonglade.Model.PostListItem
@inject IDateTimeResolver DateTimeResolver

<article class="article-post-summary">
    <div class="post-date-box d-none d-md-block">
        <div class="post-date-day">
            @DateTimeResolver.GetDateTimeWithUserTZone(Model.PubDateUtc).Day.ToString("00")
        </div>
        <div class="post-date-month">
            @DateTimeResolver.GetDateTimeWithUserTZone(Model.PubDateUtc).ToString("MMM", new CultureInfo("en-US")).ToUpper()
        </div>
    </div>
    <div class="post-summary-box">
        <time datetime="@Model.PubDateUtc.ToString("u")" class="d-none">
            @Model.PubDateUtc
        </time>

        <h4 class="post-summary-title">
            <a asp-controller="Post" asp-action="Slug"
               asp-route-year="@Model.PubDateUtc.Year"
               asp-route-month="@Model.PubDateUtc.Month"
               asp-route-day="@Model.PubDateUtc.Day"
               asp-route-slug="@Model.Slug">
                @Model.Title
            </a>
        </h4>

        <p class="post-summary-text">@(Model.ContentAbstract)</p>
        @if (null != Model.Tags)
        {
            <div class="post-summary-tags">
                @foreach (var tag in Model.Tags)
                {
                    <a asp-controller="Tags"
                       asp-action="List"
                       asp-route-normalizedName="@tag.NormalizedTagName"
                       class="post-summary-tag">
                        @tag.TagName
                    </a>
                }
            </div>
        }
    </div>
</article>